package com.twu.biblioteca;


public class User {
    private final String name;
    private final String email;
    private final String phoneNumber;
    private final String libraryNumber;
    private final String password;

    private User(UserBuilder builder) {
        this.name = builder.name;
        this.email = builder.email;
        this.phoneNumber = builder.phoneNumber;
        this.libraryNumber = builder.libraryNumber;
        this.password = builder.password;
    }

    public String getName() {
        return name;
    }

    public String getPassword() {
        return password;
    }

    public boolean matches(String libraryNumber, String password) {
        return this.libraryNumber.equals(libraryNumber) && this.password.equals(password);
    }

    @Override
    public String toString() {
        return "Name:\t" + name + "\nEmail:\t" + email + "\nPhone:\t" + phoneNumber;
    }

    public static class UserBuilder {
        private String name;
        private String email;
        private String phoneNumber;
        private String libraryNumber;
        private String password;

        public UserBuilder() {
        }

        public UserBuilder setName(String name) {
            this.name = name;
            return this;
        }

        public UserBuilder setEmail(String email) {
            this.email = email;
            return this;
        }

        public UserBuilder setPhoneNumber(String phoneNumber) {
            this.phoneNumber = phoneNumber;
            return this;
        }

        public UserBuilder setLibraryNumber(String libraryNumber) {
            this.libraryNumber = libraryNumber;
            return this;
        }

        public UserBuilder setPassword(String password) {
            this.password = password;
            return this;
        }

        public User build() {
            return new User(this);
        }

    }
}